﻿<Window x:Class="Demos.GasStations.View"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:GasStations="clr-namespace:Demos.GasStations" 
        Title="Gas Stations" Height="350" Width="850">

    <Window.Resources>
        <DataTemplate DataType="{x:Type GasStations:Coche}">
            <Grid Height="100">
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Image Source="media\coche.png" Height="150" Width="130"></Image>
                <Slider Grid.Row="1" Width="110"
                        Minimum="1" Maximum="1000" IsSnapToTickEnabled="True"
                        Value="{Binding Capacidad}">
                </Slider>
                <Label  Grid.Row="2" Content="{Binding Capacidad}" 
                       HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="85">
                </Label>
            </Grid>
        </DataTemplate>

        <DataTemplate DataType="{x:Type GasStations:Estacion}">
            <Image Source="media\gas.png" Height="80" Width="40"></Image>
        </DataTemplate>

        <DataTemplate DataType="{x:Type GasStations:Carretera}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Line X1="{Binding X1}" Y1="{Binding Y1}"
                      X2="{Binding X2}" Y2="{Binding Y2}"
                      Stroke="Black" StrokeThickness="1">
                </Line>
                <Label Grid.Row="1" Content="{Binding Longitud}"
                       HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"></Label>
            </Grid>
        </DataTemplate>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>

        <ItemsControl ItemsSource="{Binding ContenidoVisual}" BorderBrush="Transparent">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas></Canvas>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style>
                    <Setter Property="Canvas.Left" Value="{Binding X}" />
                    <Setter Property="Canvas.Top" Value="{Binding Y}" />
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>

        <Border Grid.Row="1" BorderBrush="LightGray" BorderThickness="1" Margin="5">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Button Grid.Column="0" Command="{Binding AñadirEstacionCommand}" Margin="5">Añadir Estación</Button>


                <Label Grid.Column="1" HorizontalAlignment="Right" VerticalContentAlignment="Center">Distancia:</Label>
                <TextBox Grid.Column="2" Text="{Binding DistanciaNueva, UpdateSourceTrigger=PropertyChanged}" 
                         MinWidth="60" Margin="5" VerticalContentAlignment="Center"></TextBox>

                <Label Grid.Column="3" HorizontalAlignment="Right" VerticalContentAlignment="Center">Velocidad:</Label>
                <Slider Grid.Column="4" Minimum="1" Maximum="2000" Margin="5"
                        Value="{Binding DuracionAnimacion, UpdateSourceTrigger=PropertyChanged}"></Slider>

                <Button Grid.Column="5" Command="{Binding ComenzarCommand}" Margin="5">Comenzar</Button>
                <Button Grid.Column="6" Command="{Binding BorrarCommand}" Margin="5">Borrar Estaciones</Button>
            </Grid>
        </Border>
    </Grid>
</Window>
